
if exists(select name from sysobjects where name = 'sp_LoaiSanPhamCreateEdit')
	drop proc sp_LoaiSanPhamCreateEdit
go
/*
	Created by: Phuoc NH
	Created on: 13/05/2013 (dd/mm/yyyy)
	Description: 
	--

	File:$sql-scripts/Proc.sp_LoaiSanPhamCreateEdit.sql
*/


-- =============================================
-- Author		: HP
-- Create date	: 2014-03-14
-- =============================================

CREATE PROCEDURE sp_LoaiSanPhamCreateEdit
			
	@Id            		INT,
	@TenNhomSanPham		NVARCHAR(256),
	@IdCha         		INT,
	@ThuTu         		INT,
	@TrangThai     		TINYINT
	
AS
BEGIN
    IF(@Id=0)
        BEGIN
        	INSERT INTO LoaiSanPham
        	(
		[TenNhomSanPham],
		[IdCha],
		[ThuTu],
		[TrangThai]
        	) 
        	VALUES 
        	(
		@TenNhomSanPham,
		@IdCha,
		@ThuTu,
		@TrangThai
        	)
        END
     ELSE
        BEGIN
            UPDATE LoaiSanPham     
            SET
		[TenNhomSanPham] = @TenNhomSanPham,
		[IdCha]          = @IdCha,
		[ThuTu]          = @ThuTu,
		[TrangThai]      = @TrangThai
	WHERE
		    [Id]       = @Id;
        END
END
GO


